package com.example.educationai.repository;

import com.example.educationai.entity.Exam;
import com.example.educationai.entity.ClassEntity;
import com.example.educationai.entity.SimpleUser;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import java.util.List;

public interface ExamRepository extends JpaRepository<Exam, Long> {
    List<Exam> findByClassEntity(ClassEntity classEntity);
    List<Exam> findByClassEntityOrderByExamDateDesc(ClassEntity classEntity);
    
    @Query("SELECT e FROM Exam e JOIN e.classEntity c JOIN c.students s WHERE s = :student")
    List<Exam> findByStudent(@Param("student") SimpleUser student);

    List<Exam> findByTeacher(SimpleUser teacher);
    List<Exam> findByTeacherId(Long teacherId);
} 